/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.nct.event;

import java.util.Observable;
import org.nct.cachedclient.CachedClient;
import org.nct.handler.MemCachedHandler;

/**
 *
 * @author annn
 */
public class DeleteMemCachedEvent extends Observable implements Runnable {

    MemCachedHandler handler = null;
    CachedClient client = null;

    public MemCachedHandler getHandler() {
        return handler;
    }

    public void setHandler(MemCachedHandler handler) {
        this.handler = handler;
    }

    public CachedClient getClient() {
        return client;
    }

    public void setClient(CachedClient client) {
        this.client = client;
    }

    public DeleteMemCachedEvent(CachedClient client, MemCachedHandler handler) {
        this.client = client;
        this.handler = handler;
    }

    @Override
    public void run() {

        Object obj;
        if (!this.handler.isAsync()) {
            obj = client.deteleKey(handler.getKey());
        } else {
            obj = client.deteleKey(handler.getKey(), true);
        }
        setChanged();
        notifyObservers(obj);
    }

}
